package com.gao.exceptionhandler;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author gao
 * @time 2020/07/03 16:37:25
 */
public class MyExceptionHandlerResolver implements HandlerExceptionResolver {


    public ModelAndView resolveException(HttpServletRequest httpServletRequest,
                                         HttpServletResponse httpServletResponse, Object o, Exception e) {

        if (e instanceof UnauthorizedException) {
            return new ModelAndView("unauthorized");
        }

        return null;
    }
}
